#include "Dwarf.Unmanaged.Omp.h"

using namespace std;

// The settings for this dwarf.
static Settings* settings;

// Get settings from the command line.
static int getSettings(int argc, char** argv, Solver *sgsolver) 
{
    settings = new Settings();
    if (settings->init(argc,argv,sgsolver))             //Parse all arguments for dwarf.
    {            
        delete settings;
        return -1;
    }

    //Fill result matrix.
    for (int i = 0; i < sgsolver->ymax; i ++)
    {
        for (int j = 0; j < sgsolver->xmax; j ++) 
        {
            sgsolver->tempGrid[i][j] = sgsolver->grid[i][j];
        }
    }
    return 0;
}

// Point of the program start.
void main(int argc, char** argv)
{   
    Solver* sgsolver = new Solver();        

    if (getSettings(argc, argv, sgsolver))          // Get settings from the command line.
    {
        delete sgsolver;
        exit(-1);
    }

    settings->start();                              // Start new time count.
	sgsolver->solve();                              // Solve the current problem.
    settings->finish(sgsolver);                     // Stop the time count and write results.

    //Dispose objects.
    delete settings;
    delete sgsolver;
}
